require("typescript-tools").setup({
  handlers = {
    ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "single" }),
    ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" }),
    -- ["textDocument/publishDiagnostics"] = function(err, result, ctx, config)
    --   require("ts-error-translator").translate_diagnostics(err, result, ctx, config)
    --   vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
    -- end
  },
  on_attach = function(client, bufnr)
    client.server_capabilities.semanticTokensProvider = nil
    if vim.lsp.inlay_hint then
			vim.lsp.inlay_hint.enable(true, { bufnr = 0 })
    end
  end,
  capabilities = require("lsp/tsserver").capabilities,
  settings = {
    separate_diagnostic_server = true,
    publish_diagnostic_on = "insert_leave",
    expose_as_code_action = {},
    tsserver_locale = "en",
    complete_function_calls = false,
    include_completions_with_insert_text = true,
    -- code_lens = "off",
    -- disable_member_code_lens = true,
    jsx_close_tag = {
        enable = false,
        filetypes = { "javascriptreact", "typescriptreact" },
    },
    tsserver_path = "/opt/homebrew/bin/tsserver",
    tsserver_plugins = {
      -- npm i -g typescript-language-server typescript @styled/typescript-styled-plugin typescript-styled-plugin
      -- for TypeScript v4.9+
      "@styled/typescript-styled-plugin",
      -- or for older TypeScript versions
     -- "typescript-styled-plugin",
    },
    tsserver_max_memory = "auto",
		tsserver_file_preferences = {
      includeInlayParameterNameHints = "all",
      includeCompletionsForModuleExports = true,
      quotePreference = "auto",
    },
		tsserver_format_options = {
      allowIncompleteCompletions = false,
      allowRenameOfImportPath = false,
    }
  },
})
